﻿using System;
using System.Xml;
using Notoric.Model.Internal;
using Notoric.Model.Packaging;

namespace Notoric.Model.Elements.CWNotation
{
    /// <summary>
    /// Represents a bracket.
    /// </summary>
    /// <remarks>
    /// Angular brackets are used for connecting parts in an orchestral or choral score.
    /// </remarks>
    public class Bracket : StaffConnector
    {
        #region Constructors

        /// <summary>
        /// Creates a new <see cref="Bracket"/> instance.
        /// </summary>
        /// <param name="packagePart">
        /// <para>
        /// Type: <see cref="XmlPackagePart"/>
        /// </para>
        /// <para>
        /// The package part that owns this element.
        /// </para>
        /// </param>
        /// <param name="owner">
        /// <para>
        /// Type: <see cref="System"/>
        /// </para>
        /// <para>
        /// The model element that directly owns this element.
        /// </para>
        /// </param>
        /// <param name="lowerStaff">
        /// <para>
        /// Type: <see cref="Staff"/>
        /// </para>
        /// <para>
        /// The lower connected staff.
        /// </para>
        /// </param>
        /// <param name="upperStaff">
        /// <para>
        /// Type: <see cref="Staff"/>
        /// </para>
        /// <para>
        /// The upper connected staff.
        /// </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Any of the arguments is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// The <paramref name="lowerStaff"/> is positioned above the <paramref name="upperStaff"/>.<br/>
        /// -or-<br/>
        /// The <paramref name="lowerStaff"/> or the <paramref name="upperStaff"/> does not belong to the <paramref name="owner"/> system.
        /// </exception>
        public Bracket(XmlPackagePart packagePart, System owner, Staff lowerStaff, Staff upperStaff)
            : base(packagePart, owner, lowerStaff, upperStaff)
        {

        }

        /// <summary>
        /// Creates a new <see cref="Bracket"/> instance.
        /// </summary>
        /// <param name="packagePart">
        /// <para>
        /// Type: <see cref="XmlPackagePart"/>
        /// </para>
        /// <para>
        /// The package part that owns this element.
        /// </para>
        /// </param>
        /// <param name="owner">
        /// <para>
        /// Type: <see cref="System"/>
        /// </para>
        /// <para>
        /// The model element that directly owns this element.
        /// </para>
        /// </param>
        /// <param name="element">
        /// <para>
        /// Type: <see cref="XmlElement"/>
        /// </para>
        /// <para>
        /// The XML element that holds the data of this object.
        /// </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Any of the arguments is <see langword="null"/>.
        /// </exception>
        internal Bracket(XmlPackagePart packagePart, System owner, XmlElement element)
            : base(packagePart, owner, element)
        {

        }

        #endregion

        #region StaffConnector Members

        /// <inheritdoc/>
        protected override XmlElement CreateObjectElementCore(XmlDocument document)
        {
            return document.CreateElement(
                PackageVocabulary.PackageNamespacePrefix,
                PackageVocabulary.BracketElementName,
                PackageVocabulary.PackageNamespaceUri
                );
        }

        #endregion
    }
}
